package dao;

import org.apache.ibatis.annotations.*;
import pojo.HealthTip;

import java.util.List;

public interface HealthTipMapper {
    // 查询全部，表名已改为 health_info
    @Select("SELECT * FROM health_info")
    List<HealthTip> findAll();

    // 根据ID查询，表名已改为 health_info
    @Select("SELECT * FROM health_info WHERE id = #{id}")
    HealthTip findById(Integer id);

    // 插入操作，表名已改为 health_info，注意字段与实体类属性对应
    @Insert("INSERT INTO health_info(title, content, dick_count, create_time) " +
            "VALUES(#{title}, #{content}, #{dickCount}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int addHealthTip(HealthTip healthTip);

    // 更新操作，表名已改为 health_info，注意字段与实体类属性对应
    @Update("UPDATE health_info SET " +
            "title = #{title}, " +
            "content = #{content}, " +
            "dick_count = #{dickCount}, " +
            "create_time = #{createTime} " +
            "WHERE id = #{id}")
    int updateHealthTip(HealthTip healthTip);

    // 删除操作，表名已改为 health_info
    @Delete("DELETE FROM health_info WHERE id = #{id}")
    int deleteHealthTip(Integer id);
}